<template>
	<view>
		<view class="">
			<u-tabs :list="tabList" :is-scroll="false" active-color="#FB473C" :current="tabCurrent" @change="tabChange"></u-tabs>
		</view>
		<view class="u-p-20 bg_FFFFFF">
			<view v-for="(item,index) in list" :key="index" class="u-p-20 "
				style="border-bottom: 1rpx solid #EAEAEA;margin-top: 10rpx;">
				<view class=" u-flex" @click="$u.route(`/pages/shopmassage/shopmassage?num=${item.shop_id}`)">
					<view class="u-w-94">
						<u-image :src="item.avatar" mode="aspectFill" width="93rpx" height='93rpx' shape="circle">
						</u-image>
					</view>
					<view class="u-h-100 u-m-l-24">
						<view class="u-flex u-w-580 u-row-between">
							<view class="u-weight">{{item.name}}</view>
							<view class="u-font-20" style="color: #FC3533;">下级人数：{{item.team_num}}</view>
						</view>
						<view class="u-m-t-20 u-font-20 u-flex u-row-between">
							<view class="">{{item.mobile}}</view>
							<view style="color: #898989;">{{item.partner_create_time}}注册</view>
						</view>
					</view>
				</view>
				<view class="u-m-t-20 u-flex u-font-28 cl_848484FF">
					<view class="">
						收益：{{item.profit}}
					</view>
				</view>
			</view>
			<u-loadmore :status="status" icon-type="circle" margin-top="20" margin-bottom="20" />
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				tabList: [{
					name: '直推合伙人',
					api:'partner_zt_list'
				}, {
					name: '间推合伙人',
					api:'partner_jt_list'
				}],
				tabCurrent: 0,
				list: [],
				params: {
					page: 1,
					page_size: 20
				},
				status: 'loadmore',
			}
		},
		onLoad(load) {
			this.clear()
			this.comApi(this.tabList[this.tabCurrent].api)
		},
		// 下拉到底事件
		onReachBottom() {
			//避免多次触发
			if (this.status == 'loading' || this.status == 'nomore') {
				return;
			}
			this.comApi(this.tabList[this.tabCurrent].api)
		},
		methods: {
			tabChange(index){
				this.tabCurrent=index
				this.clear()
				this.comApi(this.tabList[this.tabCurrent].api)
			},
			clear() {
				this.params.page = 1
				this.list = []
			},
			async comApi(apiName) {
				await this.$api[apiName](this.params, res => {
					if (res.data.code == 1) {
						if (res.data.code == 1) {
							if (res.data.data.data.length < 20) {
								this.status = 'nomore';
							} else {
								this.params.page = this.params.page + 1;
								this.status = 'loadmore';
							}
							this.list = this.list.concat(res.data.data.data);
							uni.stopPullDownRefresh();
						}
					}
				})
			}
		}
	}
</script>

<style scoped>
</style>
